class Solution {
    public int compare(String str1, String str2) {
        int len1 = str1.length();
        int len2 = str2.length();
        int sum1 = 0;
        int sum2 = 0;
        for (int i = 0; i < len1; i++) {
            int x = str1.charAt(i) - 48;
            sum1 += x * Math.pow(10,len1-i-1);
        }
        for (int i = 0; i < len2; i++) {
            int x = str2.charAt(i) - 48;
            sum2 += x * Math.pow(10,len2-i-1);
        }
        if (sum1 == sum2) {
            return 0;
        } else if (sum1 > sum2) {
            return 1;
        }
        return -1;
    }
    public int compareVersion(String version1, String version2) {
        String[] str1 = version1.split("\\.");
        String[] str2 = version2.split("\\.");
        int len = Math.min(str1.length, str2.length);
        for (int i = 0; i < len; i++) {
            int x = compare(str1[i],str2[i]);
            if (x != 0) {
                return x;
            }
        }
        String str = "0";
        if (str1.length > str2.length) {
            for (int i = len; i < str1.length; i++) {
                int x = compare(str1[i],str);
                if (x != 0) {
                    return 1;
                }
            }
        }
        if (str1.length < str2.length) {
            for (int i = len; i < str2.length; i++) {
                int x = compare(str2[i],str);
                if (x != 0) {
                    return -1;
                }
            }
        }
        return 0;
    }
}




class Solution {
    class Stringchild implements Comparable<Stringchild> {
        public String str;

        public Stringchild(String str) {
            this.str = str;
        }

        @Override
        public int compareTo(Stringchild o) {
            int len1 = this.str.length();
            int len2 = o.str.length();
            int sum1 = 0;
            int sum2 = 0;
            for (int i = 0; i < len1; i++) {
                int x = this.str.charAt(i) - 48;
                sum1 += x * Math.pow(10,len1-i-1);
            }
            for (int i = 0; i < len2; i++) {
                int x = o.str.charAt(i) - 48;
                sum2 += x * Math.pow(10,len2-i-1);
            }
            if (sum1 == sum2) {
                return 0;
            } else if (sum1 > sum2) {
                return 1;
            }
            return -1;
        }
    }
    public  int compareVersion(String version1, String version2) {
        String[] str1 = version1.split("\\.");
        String[] str2 = version2.split("\\.");
        int len = Math.min(str1.length, str2.length);
        for (int i = 0; i < len; i++) {
            Stringchild child1 = new Stringchild(str1[i]);
            Stringchild child2 = new Stringchild(str2[i]);
            int x = child1.compareTo(child2);
            if (x != 0) {
                return x;
            }
        }
        Stringchild child = new Stringchild("0");
        if (str1.length > str2.length) {
            for (int i = len; i < str1.length; i++) {
                Stringchild child1 = new Stringchild(str1[i]);
                int x = child1.compareTo(child);
                if (x != 0) {
                    return 1;
                }
            }
        }
        if (str1.length < str2.length) {
            for (int i = len; i < str2.length; i++) {
                Stringchild child2 = new Stringchild(str2[i]);
                int x = child2.compareTo(child);
                if (x != 0) {
                    return -1;
                }
            }
        }
        return 0;
    }
}